<template>
  <div>
    <Card >
        <Tabs value="name1" @on-click="onTab">
            <TabPane label="全部" name="name1"><Table :columns="columns1" :data="data1"></Table></TabPane>
            <TabPane label="合伙人" name="name2"><Table :columns="columns1" :data="data1"></Table></TabPane>
            <TabPane label="代理人" name="name3"><Table :columns="columns1" :data="data1"></Table></TabPane>
            <TabPane label="会员" name="name4"><Table :columns="columns1" :data="data1"></Table></TabPane>
        </Tabs>
      <div class="page" style="margin-top: 20px">
        <Page :total="total" show-sizer size="small"
              :page-size="pageSize"
              :page-size-opts="$app.pageAll.pageSizeOpts"
              :current = 'page'
              @on-change="loadMore"
              @on-page-size-change="changePageSize"
        ></Page>
      </div>
    </Card>
  </div>
</template>

<script>

export default {
  name: 'team',
  data () {
    return {
      page: 1, // 当前页数
      pageSize: $app.pageAll.pageSize, // 默认数据返回条数
      total: 0, // 所有数据条数
      total_page: 0, // 所有页面
      type:'0',
      columns1: [
        {
          type: 'index',
          title:'序号',
          width:100,
          align: 'center'
        },
        {
          title: '公司名称',
          key: 'company_name',
          align: 'center'
        },
        {
          title: '手机号',
          key: 'mobile',
          align: 'center'
        },
        {
          title: '地址',
          key: 'province',
          align: 'center'
        },
        {
          title: '注册时间',
          key: 'created_at',
          align: 'center'
        }
      ],
      data1: [] // 数据
    }
  },
  mounted () {
    this.getPartnerInviteList();
  },
  methods: {
      // 切换
      onTab (name) {
          this.page = 1;
          if (name == 'name1') {
              this.type = 0;
          }else if(name == 'name2') {
              this.type = 1;
          }else if(name == 'name3') {
              this.type = 2;
          }else if(name == 'name4') {
              this.type = 3;
          }
          this.getPartnerInviteList();
      },
        // 获取提现申请列表
        getPartnerInviteList () {
          const page = this.page;
          const pageSize = this.pageSize;
          const type = this.type;
          $ajax.lb_getPartnerInviteList({type,page,pageSize}, res => {
            this.data1 = res.data.list;
            this.total = res.data.total;
            this.total_page = res.data.total_page;
          });
        },
      // 加载更多
      loadMore (page) {
          this.page = page;
          this.getPartnerInviteList()
      },
      // 数据返回条
      changePageSize(pageSize) {
          this.pageSize = pageSize;
          this.getPartnerInviteList()
      },
  }
}
</script>

